angular.module('myApp').controller('MainCtrl', ['$scope', 'DataService', '$location', function ($scope, DataService, $location) {
  console.log($location.path());
  
  $scope.activeIndex = sessionStorage.getItem('activeIndex') || '';
  $scope.menuData = [
    {
      index: "1",
      title: "处理中心",
      children: [
        {
          index: "1-1",
          title: "处理中心",
          to: "/main",
        },
        {
          index: "1-2",
          title: "处理中心1",
          children: [
            {
              index: "1-2-1",
              title: "处理中心1-2",
              to: "/message",
            }
          ]
        }
      ]
    },
    {
      index: "2",
      title: "Basic",
      children: [
        {
          index: "2-1",
          title: "Button 按钮",
          to: "/button",
        },
        {
          index: "2-2",
          title: "Radio 单选框",
          to: "/radio"
        },
        {
          index: "2-3",
          title: "Link 文字链接",
          to: "/link"
        },
        {
          index: "2-4",
          title: "Layout 布局",
          to: "/layout"
        }
      ]
    },
    {
      index: "3",
      title: "Form",
      children: [
        {
          index: "3-1",
          title: "Form 表单",
          to: "/form",
        },
        {
          index: "3-2",
          title: "Radio 单选框",
          to: "/radio"
        },
        {
          index: "3-3",
          title: "Checkbox 多选框",
          to: "/checkBoxGroup"
        },
        {
          index: "3-4",
          title: "Input 输入框",
          to: "/input"
        },
        {
          index: "3-5",
          title: "Select 选择器",
          to: "/select"
        },
        {
          index: "3-6",
          title: "Switch 开关",
          to: "/switch"
        },
        {
          index: "3-7",
          title: "TimePicker 时间选择器",
          to: "/timePicker"
        },
        {
          index: "3-8",
          title: "Upload 上传",
          to: "/upload"
        },
        {
          index: "3-9",
          title: "DatePicker 日期选择器",
          to: "/datePicker"
        },
        {
          index: "3-10",
          title: "Transfer 穿梭框",
          to: "/transfer"
        },
        {
          index: "3-11",
          title: "Cascader 级联选择器",
          to: "/cascader"
        }
      ]
    },
    {
      index: "4",
      title: "Data",
      children: [
        {
          index: "4-1",
          title: "Table 表格(有问题)",
          to: "/table",
        },
        {
          index: "4-2",
          title: "Pagination 分页",
          to: "/pagination"
        },
        {
          index: "4-3",
          title: "Descriptions 描述列表(有问题)",
          to: "/descriptions"
        },
        {
          index: "4-4",
          title: "Tag 标签",
          to: "/tag"
        },
        {
          index: "4-5",
          title: "Progress 进度条",
          to: "/progress"
        },
        {
          index: "4-6",
          title: "Badge 标记",
          to: "/badge"
        }
      ]
    },
    {
      index: "5",
      title: "Navigation",
      children: [
        {
          index: "5-1",
          title: "Tabs 标签页",
          to: "/tabs",
        },
        {
          index: "5-2",
          title: "Dropdown 下拉菜单",
          to: "/dropdown",
        },
        {
          index: "5-3",
          title: "Breadcrumb 面包屑",
          to: "/breadcrumb",
        },
      ]
    },
    {
      index: "6",
      title: "Others",
      children: [
        {
          index: "6-1",
          title: "Dialog 对话框",
          to: "/dialog",
        },
        {
          index: "6-2",
          title: "Collapse 折叠面板",
          to: "/collapse",
        },
        {
          index: "6-3",
          title: "Card 卡片",
          to: "/card",
        },
        {
          index: "6-4",
          title: "Carousel 走马灯",
          to: "/carousel",
        },
        {
          index: "6-5",
          title: "Popconfirm 气泡确认框",
          to: "/popconfirm",
        }
      ]
    }
  ];
  $scope.handleSelect = function (selected) {
    sessionStorage.setItem('activeIndex', selected)
    $scope.activeIndex = selected
    console.log('选中菜单:', selected);
    DataService.set({ index: selected });
  };
  $scope.search = () => {
    console.log(123);
  }
}])
  .directive('elMenu', elMenu)
  .directive('elMenuItem', ['$location','ColorService', elMenuItem])
  .directive('elSubmenu',['$timeout', 'ColorService', elSubmenu])
  .directive('elTag', elTag)
  .directive('elMenuItemGroup', elMenuItemGroup)
  .directive('elContainer', elContainer)
  .directive('elAside', elAside)
  .directive('elHeader', elHeader)
  .directive('elMain', elMain);